using WordbankSDK.Enum;

namespace WordbankSDK
{
    /// <summary>
    /// 接口基类
    /// </summary>
    public class Base
    {
        /// <summary>
        /// 调用官方接口的访问地址HOST
        /// </summary>
        public string Host { get; private set; } = "api.worldbank.org";
        /// <summary>
        /// 调用官方接口版本(v2)
        /// </summary>
        public string Version { get; private set; } = "v2";
        /// <summary>
        /// 是否启用HTTPS - 超文本传输安全协议
        /// </summary>
        public bool IsUseHttps { get; set; } = false;
        /// <summary>
        /// 接口返回数据类型 default - Json
        /// </summary>
        /// <value></value>
        public DataFormats Formats { get; set; } = DataFormats.Json;


        /// <summary>
        /// 重置默认的接口地址
        /// </summary>
        /// <param name="host">default - "api.worldbank.org"</param>
        /// <param name="version">default - "v2"</param>
        public void SetUrl(string host, string version = "v2")
        {
            Host = host;
            Version = version;
        }

        /// <summary>
        /// 接口访问基地址
        /// </summary>
        /// <value></value>
        public string BaseUrl
        {
            get
            {
                return IsUseHttps ? string.Format("https://{0}/{1}/", Host, Version) : string.Format("https://{0}/{1}/", Host, Version);
            }
        }
    }
}